import {
  FlowNodeInputTypeEnum,
  FlowNodeOutputTypeEnum,
  FlowNodeTemplateTypeEnum,
  FlowNodeTypeEnum,
  NodeInputKeyEnum,
  NodeOutputKeyEnum,
  WorkflowIOValueTypeEnum,
} from '@/types/workflow/constant';
import { FlowNodeTemplateType } from '@/types/workflow/node';
import { getHandleConfig } from '../../utils';
import { Input_Template_Stream_MODE } from '../../input';

export const FetchUrlModule: FlowNodeTemplateType = {
  id: FlowNodeTypeEnum.fetchUrl,
  templateType: FlowNodeTemplateTypeEnum.tools,
  flowNodeType: FlowNodeTypeEnum.pluginModule,
  sourceHandle: getHandleConfig(true, true, true, true),
  targetHandle: getHandleConfig(true, true, true, true),
  avatar: 'fetchUrl.svg',
  name: '网页抓取',
  intro: '一个用于抓取网页的插件，仅支持获取静态网站，返回的数据格式为 Markdown。',
  showStatus: true,
  isTool: true,
  version: '481',
  isFolded: true,
  pluginId: 'community-fetchUrl',
  inputs: [
    // Input_Template_Stream_MODE,
    {
      key: NodeInputKeyEnum.url,
      renderTypeList: [FlowNodeInputTypeEnum.reference, FlowNodeInputTypeEnum.input],
      label: '需要抓取的网页链接',
      value: '',
      valueType: WorkflowIOValueTypeEnum.string,
      selectedTypeIndex: 0,
      canEdit: false,
      required: true,
    },
  ],
  outputs: [
    {
      id: NodeOutputKeyEnum.result,
      key: NodeOutputKeyEnum.result,
      label: '网页抓取结果',
      description: '网页抓取结果',
      valueType: WorkflowIOValueTypeEnum.string,
      type: FlowNodeOutputTypeEnum.static,
    },
  ],
};
